<html>
    <head>
        <title>My first PHP Website</title>
    </head>
   <?php
   session_start(); //starts the session
   if($_SESSION['user']){ // checks if the user is logged in  
   }
   else{
      header("location: index.php"); // redirects if user is not logged in
   }
   $user = $_SESSION['user']; //assigns user value
   ?>
    <body>
        <h2>Pagina historial........</h2>
        
<hello>! </hello>
 <!--Display's user name-->
          <a href="logout.php">Click here to go logout</a><br/><br/>
        <form action="add.php" method="POST">
           Add more to list: <input type="text" name="details" /> <br/>
           Public post? <input type="checkbox" name="public[]" value="yes" /> <br/>
           <input type="submit" value="Add to list"/>
        </form>

<table border="1px" width="100%">
            <tr>
                <th>Id</th>
                <th>Description</th>
                <th>Diagnostico</th>
                <th>Name</th>
                <th>Location</th>
                <th>Tipo</th>
                <th>Fecha Post</th>
            </tr>
 <?php
            mysql_connect("localhost", "root","admin") or die(mysql_error()); //Connect to server
            mysql_select_db("InfMedicas") or die("Cannot connect to database"); //Connect to database


                $query = mysql_query("Select * from picture"); // SQL Query
                while($row = mysql_fetch_array($query))
                {
                    echo "<tr>";
                        echo '<td align="center">'. $row['id'] . "</td>";
                        echo '<td align="center">'. $row['description'] . "</td>";
                        echo '<td align="center">'. $row['result'] . "</td>";
                        echo '<td align="center">'. $row['name'] . "</td>";
                        echo '<td align="center">'. $row['location']. "</td>";
                        echo '<td align="center">'. $row['type'] . "</td>";
                        echo '<td align="center">'. $row['meal_date'] . "</td>";
                    echo "</tr>";
                }
            ?>
        </table>
    </body>
</html>